<!DOCTYPE html>
<html xmlns:>

<head>
    <meta charset="UTF-8">
    <title>编辑管理员-WeAdmin Frame型后台管理系统-WeAdmin 1.0</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="/resource/backend/css/font.css">
    <link rel="stylesheet" href="/resource/backend/css/weadmin.css">
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
    <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
    <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>

<body>
<div class="weadmin-body">
    <form class="layui-form">
        <div class="layui-form-item">
            <label class="layui-form-label">
                <span class="we-red">*</span>用户名
            </label>
            <div class="layui-input-inline">
                <input type="text" name="username"
                       value="${.admin.Username}$"
                       autocomplete="off" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">
                <span class="we-red">*</span>将会成为您唯一的登入名
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">
                <span class="we-red">*</span>姓名
            </label>
            <div class="layui-input-inline">
                <input type="text" name="name"
                       value="${.admin.Name}$"
                       autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">
                <span class="we-red">*</span>手机
            </label>
            <div class="layui-input-inline">
                <input type="text"name="tel"
                       value="${.admin.Tel}$"
                       autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">
                <span class="we-red">*</span>邮箱
            </label>
            <div class="layui-input-inline">
                <input type="text" name="email"
                       value="${.admin.Email}$"
                       autocomplete="off" class="layui-input">
            </div>

        </div>
        <div class="layui-form-item">
            <label class="layui-form-label"><span class="we-red">*</span>角色</label>
            <div class="layui-input-block">
                ${range $key, $item := $.roleIdTitleArr}$
                <input type="checkbox" name="role[]" title="${$item.Title}$" value="${$item.Id}$" lay-skin="primary"
                       ${range $_key, $_item := $.roleAccounts}$
                       ${if eq $item.Id $_item.RoleId}$checked${end}$
                       ${end}$
                >
                ${end}$
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label"><span class="we-red">*</span>状态</label>
            <div class="layui-input-block">
                <input type="checkbox" name="status" lay-skin="switch" value="1" lay-text="启用|停用" ${if eq .admin.Status 1}$checked${end}$>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">
                密码
            </label>
            <div class="layui-input-inline">
                <input type="password" name="password"
                       autocomplete="off" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">
                6到16个字符，不填密码将不修改密码
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">
                确认密码
            </label>
            <div class="layui-input-inline">
                <input type="password" name="re_password"
                       autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label"></label>
            <input type="hidden" name="id" value="${.admin.Id}$">
            <button  class="layui-btn" lay-filter="edit" lay-submit="">修改</button>
        </div>
    </form>
</div>
<script src="/resource/backend/lib/layui/layui.js" charset="utf-8"></script>
<script type="text/javascript">
    layui.extend({
        admin: '{/}/resource/backend/js/admin'
    });
    layui.use(['form','layer','admin'], function(){
        var form = layui.form,
            admin = layui.admin,
            $   = layui.$,
            layer = layui.layer;
        form.render();
        //监听提交
        form.on('submit(edit)', function(data){
            var serialize = $('.layui-form').serializeArray();
            console.log(data);
            console.log(serialize);
            $.post('${backend_api_url `/admin/edit`}$',data.field,function(res){
                if(res.code === 0){
                    layer.msg("修改成功", {icon: 6,time:800},function () {
                        // 获得frame索引
                        var index = parent.layer.getFrameIndex(window.name);
                        //关闭当前frame
                        parent.layer.close(index);
                        parent.location.reload();
                    });
                }else{
                    layer.msg(res.message,{icon:5});
                }

            });
            return false;
        });
    });
</script>
</body>

</html>